A Look at Gas Prices During the COVID Pandemic

Made by Erica Sprott and Jacquelyn Maly, 2021

1. Preparing the Data

This data, gathered from kaggle, includes gas prices from 1995 through 2021. Though it includes a column with average gas price for all formulations and grades, it can also break down the data into those subcategories. The included grades are regular, midrange, and premium; while the included formulations are conventional and reformulated. Data is specific to the United States.

First we want to rename the columns to make them easier to understand. In the following table,

Next, we want to change the date column to a datetime object in pandas.

Finally, we want to check and see if there are any missing variables. According to the output below, there are not any missing variables, so the data cleaning process for this dataset is pretty easy.

Finally, let's take a look at the shape of the gas dataset. According to the output below, there are 14 variables and 1361 entries. We can look at a sample of the gas dataset to see a random entry.

2. Taking a sample for data visualization

We chose to take a sample of teh last 1500 observations because it was more relevant for our timeline -- we really wanted to focus on the effect of the COVID pandemic with some context of gas price trends from the preceeding years.

3. Data Visualization

Let's first take a look at all gas prices for all formulas and grades between 1995 and 2021. This will give us some context for what the trends in gas prices have been over the last 3 decades. Then we can split up the data into different formulations and different grads to see if any trends exist there.

Let's take a smaller sample so we can focus on the last few years.

Now that we're focusing on the last four years, we can see a huge dip at the beginning of 2020 as quarantine begins. Overall gas prices drop below 2 dollars per gallon in early April of 2020. Our hover data shows us that this tipping point came between April 6th and April 13th, where prices dropped from 2.022 to 1.95 dollars per gallon.

What if we split up the trends into different formulations and grades? First, we need to melt the dataframe so we can show each different value on the y axis at the same time. We'll keep Date as a column as the identifier variable.

Then, plot by date with each different gas variation in beautiful rainbow colors.

Gas prices were already falling in winter of 2019-2020 because it was one of the warmest winters on record -- people just didn't need to use as much gas for things like heating their homes. Of course, this trend continued into spring of 2020 as people stayed home to quarantine.

Finally, we can see that almost all the gas prices follow the same trend, we can see, singled out in green above, tha deisel prices didn't drop as much during the COVID lockdown as the other gas prices did. Let's isolate deisel trends specifically in another graph below.

As we can see above, diesel prices didn't experience the same severe dip like other gas prices did. Overall, it didn't drop much below 2.4 on average. This could be due to a less elastic demand for diesel. Large and long distance trucks often use diesel because it provides more torque. If trucking was considered an essential business during lockdown, this could explain this smaller impact on gas prices.